<!-- 用户管理 -->
<template>
  <div class="app-container">
    <el-row :gutter="20">

      <!-- 日志列表 -->
      <el-col :lg="24" :xs="24">

        <el-card shadow="hover" class="data-table">
          
          <el-table
            v-loading="loading"
            :data="pageData"
            border
            stripe
            highlight-current-row
            class="data-table__content"
          >
            
            <el-table-column label="管理员Id" prop="adminId" />
            <el-table-column label="用户名" prop="adminUser" />
            <el-table-column label="类型" prop="type" >
              <template #default="{ row }">
                <span v-if="row.type === 1">USDT加减</span>
                <span v-else-if="row.type === 2">积分加减</span>
                <span v-else-if="row.type === 3">提现审核</span>
                <span v-else-if="row.type === 4">配置修改</span>
              </template>
            </el-table-column>
            <el-table-column label="数额" prop="amount" />
            <el-table-column label="备注" prop="remark" />
            <el-table-column label="添加时间" prop="createTime" />


          </el-table>

          <pagination
            v-if="total > 0"
            v-model:total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="fetchData"
          />
        </el-card>
      </el-col>
    </el-row>

    <!-- <UserImport v-model="importDialogVisible" @import-success="handleQuery()" /> -->
  </div>
</template>

<script setup lang="ts">

import UserAPI from "@/api/system/user.api";

defineOptions({
  name: "UserLog",
  inheritAttrs: false,
});


const queryParams = reactive<any>({
  pageNum: 1,
  pageSize: 10,
});

const pageData = ref<any>();
const total = ref(0);
const loading = ref(false);

// 获取数据
async function fetchData() {
  loading.value = true;
  try {
    queryParams.page = queryParams.pageNum;
    queryParams.limit = queryParams.pageSize;

    const lists = await UserAPI.getLogPage(queryParams);
    const arr = [
      "算力","能量","会员卡","矿机"
    ]

    if (lists.data?.length === 0) {
      pageData.value = [{
      "adminId": 1,
      "type": arr[3], //1:算力 2:能量 3:会员卡 4:矿机
      "amount": "4000.00", //数量
      "remark": "管理员测试", //备注
      "createTime": "2025-04-22 17:17:44", //时间
      "adminUser": "admin01" //管理员账户
      }];
      total.value = 1;
      return;
    }
    pageData.value = lists.data;
    total.value = lists.total
  } finally {
    loading.value = false;
  }
}

onMounted(() => {
  fetchData();
});
</script>
